package com.workingpub.commons.resource.internal;

import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;

import com.workingpub.commons.resource.ActivatorSupport;

public class Activator extends ActivatorSupport {

	private ConfigAdmin configAdmin;

	private static Activator instance;

	public Activator() {
		instance = this;
	}

	public static Activator getInstance() {
		return instance;
	}

	@Override
	protected void doStartThings() throws Exception {
		configAdmin = new ConfigAdmin();
		configAdmin.init();
	}

	@Override
	protected void doStopThings() throws Exception {
		configAdmin.destory();
	}

	Configuration[] getConfigurations(String pidFilter) throws Exception {
		ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class);
		if (null == configAdmin) {
			return null;
		}
		Configuration[] commonsConfigs = configAdmin.listConfigurations(pidFilter);
		return commonsConfigs;
	}
}
